package com.github.cyf.interceptor.encrypt.impl;

import com.github.cyf.interceptor.encrypt.IEncryptResultFieldStrategy;
import com.github.cyf.util.AESUtil;
import org.springframework.stereotype.Component;

/**
 * @author chenyifan
 * @create 2024-04-14 18:43
 */
@Component
public class AESEncryptStrategy implements IEncryptResultFieldStrategy {

    @Override
    public String encrypt(String source) {
        if (source == null) {
            return null;
        }
        try {
            return AESUtil.encrypt(source);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
